﻿package frEngine.shader.filters.fragmentFilters.extra
{
    import __AS3__.vec.*;
    import baseEngine.system.*;
    import flash.geom.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.fragmentFilters.*;

    public class OutLightingFilter extends FragmentFilter
    {
        public var outColor:Vector.<Number>;
        public var cameraPos:Vector.<Number>;
        private var outConst:Vector.<Number>;

        public function OutLightingFilter(param1:Array = null)
        {
            this.outColor = this.Vector.<Number>([1, 0, 0, 1]);
            this.cameraPos = this.Vector.<Number>([0, 0, 0, 1]);
            this.outConst = this.Vector.<Number>([20, 1.8, 100, 1.1]);
            super(param1);
            type = FilterType.OutLightingFilter;
            _priority = FilterPriority.OutLightingFilter;
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{CamPos}", false).value = this.cameraPos;
            param1.getParamByName("{OutColor}", false).value = this.outColor;
            param1.getParamByName("{OutConst}", false).value = this.outConst;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "OutLightingFilter";
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:Array = [new ToBuilderInfo("vf1", "{V_GloblePos}", false, 1)];
            param1.toBuild("", _loc_3);
            return "";
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fc1", "{CamPos}", false, 1, this.cameraPos));
            _loc_3.push(new ToBuilderInfo("fc2", "{OutColor}", false, 1, this.outColor));
            _loc_3.push(new ToBuilderInfo("fm0", FilterName.global, true, 4));
            _loc_3.push(new ToBuilderInfo("fc3", "{OutConst}", false, 1, this.outConst));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + ("sub ft1, {CamPos}, {V_GloblePos} \n" + "nrm ft1.xyz, ft1 \n" + "m33 ft2.xyz,{vnormal},fm0 \n" + "dp3 ft3.x, ft1.xyz, ft2.xyz \n" + "sat ft3.x, ft3.x  \n" + "pow ft3.x, ft3.x, {OutConst}.y \n" + "mul ft3.x, ft3.x, {OutConst}.x \n");
            return null;
        }// end function

        public function updateCameraPos() : void
        {
            var _loc_1:* = Global3D.camera.pos;
            this.cameraPos[0] = _loc_1.x;
            this.cameraPos[1] = _loc_1.y;
            this.cameraPos[2] = _loc_1.z;
            this.cameraPos[3] = 1;
            return;
        }// end function

    }
}
